


//页面状态相关
let status = {
  //当前选中的标签
  selectedTabs: 'importRecords',
};

// 和网络交互相关的参数
let params = {
};

// 页面的数据源
let data = {
  importRecordList: [],
  getInfoRecordList: []
};

// 页码相关
let getInfoRecordPage = {
  total: 1,
  startIndex: 0,
  stepNumber: 40,
  currentPage: 1
};

// 页码相关
let importRecordPage = {
  total: 1,
  startIndex: 0,
  stepNumber: 40,
  currentPage: 1
};

//记录列表
let importRecordTable = function (self) {
  return [
    {
      type: 'index',
      title: '#',
      width: 70,
      key: 'index',
      fixed: 'left',
      align: 'center'
    },
    {
      title: '来源',
      width: 120,
      key: 'channel',
      render: (h, params) => {
        let type = "";
        let platform = self.customerPlatforms.filter(item => item.type == params.row.channel)[0];
        if(platform){
          type = platform.platform;
        }
        return h('div', type);
      }
    },
    {
      title: '关键字',
      key: 'keyword'
    },
    {
      title: '用户数(去重前)',
      width: 140,
      key: 'orginalNumber'
    },
    {
      title: '用户数(去重后)',
      width: 140,
      key: 'mergedNumber',
    },
    {
      title: '实际导入数据库',
      width: 150,
      key: 'importNumber',
    },
    {
      title: '导入时间',
      width: 150,
      key: 'createtime',
      render: (h, params) => {
        return h('div', self.$tiyBJTime(params.row.createtime));
      }
    }
  ];
}

//记录列表
let getInfoRecordTable = function () {
  return [
    {
      type: 'index',
      title: '#',
      width: 70,
      key: 'index',
      fixed: 'left',
      align: 'center',
    },
    {
      title: '批次',
      width: 120,
      key: 'numberProfix'
    },
    {
      title: '本批次用户数',
      width: 120,
      key: 'planNumber'
    },
    {
      title: '开始时间',
      width: 150,
      key: 'starttime',
      render: (h, params) => {
        return h('div', self.$tiyBJTime(params.row.starttime));
      }
    },
    {
      title: '成功数量',
      width: 100,
      key: 'successNumber',
    },
    {
      title: '失败数量',
      width: 100,
      key: 'failureNumber',
    },
    {
      title: '抓取状态',
      width: 120,
      key: 'state',
      render:(h, params) =>{
        return h('div', params.row.endtime?'已完成':'进行中');
      }
    },
    {
      title: '完成时间',
      width: 150,
      key: 'endtime',
      render: (h, params) => {
        if(params.row.endtime){
          let date = new Date(params.row.endtime);
          return h('div', self.$tiyBJTime(params.row.endtime));
        } else {
          return h('div', '');
        }
      }
    }
  ];
}

export  default  {
  tStatus: status,
  tParams: params,
  tData: data,
  tGetInfoRecordPage: getInfoRecordPage,
  tImportRecordPage: importRecordPage,
  getInfoRecordTable:getInfoRecordTable,
  importRecordTable:importRecordTable
};
